Source File
xtypes.go
Belonging Package
github.com/ChrisTrenkamp/goxpath/tree
package treeimport ()//Boolean stringsconst (True = "true"False = "false")//Bool is a boolean XPath typetype Bool bool//ResValue satisfies the Res interface for Boolfunc ( Bool) () string {if {return True}return False}//Bool satisfies the HasBool interface for Bool'sfunc ( Bool) () Bool {return}//Num satisfies the HasNum interface for Bool'sfunc ( Bool) () Num {if {return Num(1)}return Num(0)}//Num is a number XPath typetype Num float64//ResValue satisfies the Res interface for Numfunc ( Num) () string {if math.IsInf(float64(), 0) {if math.IsInf(float64(), 1) {return "Infinity"}return "-Infinity"}return fmt.Sprintf("%g", float64())}//Bool satisfies the HasBool interface for Num'sfunc ( Num) () Bool {return != 0}//Num satisfies the HasNum interface for Num'sfunc ( Num) () Num {return}//String is string XPath typetype String string//ResValue satisfies the Res interface for Stringfunc ( String) () string {return string()}//Bool satisfies the HasBool interface for String'sfunc ( String) () Bool {return Bool(len() > 0)}//Num satisfies the HasNum interface for String'sfunc ( String) () Num {, := strconv.ParseFloat(strings.TrimSpace(string()), 64)if != nil {return Num(math.NaN())}return Num()}//NodeSet is a node-set XPath typetype NodeSet []Node//GetNodeNum converts the node to a string-value and to a numberfunc ( Node) Num {return String(.ResValue()).Num()}//String satisfies the Res interface for NodeSetfunc ( NodeSet) () string {if len() == 0 {return ""}return [0].ResValue()}//Bool satisfies the HasBool interface for node-set'sfunc ( NodeSet) () Bool {return Bool(len() > 0)}//Num satisfies the HasNum interface for NodeSet'sfunc ( NodeSet) () Num {return String(.String()).Num()}
![]() |
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |